<?php
require_once('../model/class.user.php');
$qiUser = new qiUser($DB);

if($ts == 'list')
{
$pageurl = '';
$page = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1;
$pageurl .= './index.php?action=user&ts=list&page';
$users = $qiUser->getUsers($page,8);

$virtue = "id";
$setvirtue = "id";
$usernum = $qiUser->getUserNum($virtue, $setvirtue);

$page_url = pagination($usernum, 8, $page, $pageurl);

}

if($ts == 'edit')
{
$uid = isset($_GET['id']) ? $_GET['id'] : '';
$userDate = $qiUser->getOneUser($uid);
}

if($ts == 'update')
{
$username = isset($_POST['username']) ? $_POST['username'] : '';
$truename = isset($_POST['truename']) ? $_POST['truename'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$isadmin = isset($_POST['isadmin']) ? $_POST['isadmin'] : '';
$gag = isset($_POST['gag']) ? $_POST['gag'] : '';

$uid = isset($_GET['id']) ? $_GET['id'] : '';

$userDate = array(
'username' => $username,
'truename' => $truename,
'email' => $email,
'isadmin' => $isadmin,
'gag' => $gag
);

$qiUser->updateUser($userDate,$uid);

header("Location: index.php?action=user&ts=list");

}

if($ts == 'del')
{
$uid = isset($_GET['id']) ? $_GET['id'] : '';
$qiUser->deleteUser($uid);
header("Location: index.php?action=user&ts=list");
}

?>